package com.gjy.work.alipay.config;

import com.alipay.api.AlipayConfig;
import com.gjy.work.alipay.properties.AliPayProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * @author gjy
 * @version 1.0
 * @since 2025-05-09 08:35:34
 */
@Configuration
public class AliPayMsgConfig {

    @Resource
    private AliPayProperties aliPayProperties;

    @Bean
    public AlipayConfig config() {
        AlipayConfig alipayConfig = new AlipayConfig();
        alipayConfig.setServerUrl(aliPayProperties.getGatewayHost());
        alipayConfig.setAppId(aliPayProperties.getAppId());
        alipayConfig.setPrivateKey(aliPayProperties.getMerchantPrivateKey());
        alipayConfig.setFormat("JSON");
        alipayConfig.setAlipayPublicKey(aliPayProperties.getAlipayPublicKey());
        alipayConfig.setCharset("UTF-8");
        alipayConfig.setSignType("RSA2");
        return alipayConfig;
    }
}
